
function edit(id){
	var url = 'edit_supplier.html?'+id;
	var config = 'dialogWidth:240px;dialogHeight:205px;scroll:no;status:no;';
	window.showModalDialog(url,'',config);
//	window.open(url,'',config);
	selectSupplier();
};
function selectSupplier(){
	var supplier_name = escape(escape(document.getElementById('supplier_name').value));
	var supplier_man = escape(escape(document.getElementById('supplier_man').value));
	var supplier_type = escape(escape(document.getElementById('supplier_type').value));
	supplier_type = supplier_type==''?-1:supplier_type;
	var supplier_comment = escape(escape(document.getElementById('supplier_comment').value));
	supplier_comment = supplier_comment==''?-1:supplier_comment;
	
	var url = '/storage/manager/pages/supplier.do?method=selectSupplier&d=' + new Date();
	url = url + '&supplier_name='+supplier_name;
	url = url + '&supplier_man='+supplier_man;
	url = url + '&supplier_type='+supplier_type;
	url = url + '&supplier_comment='+supplier_comment;
	
	$.getJSON(url, {}, function(data){
		$('#supplier_list').html('');

		var _max = get_max_line(470,25);
		
		for(var i=0;i<data.length;i++){
			var comment = '';
			if(data[i][6]==0){
				comment = '优';
			}else if(data[i][6]==1){
				comment = '良';
			}else{
				comment = '差';
			}
			var style_border = 0-(0-i-1)==data.length&&data.length>=_max?'style="border-bottom:0;"':'';
			var supplierList = '';
			supplierList = supplierList + '<tr style="height:25px;" onmouseover="cbgcolor(this,0)" onmouseout="cbgcolor(this,1)">';
			supplierList = supplierList + '  <td class="list" '+style_border+' width="92" >'+(data[i][7]==0?'供应商':'客户')+'</td>';
			supplierList = supplierList + '  <td class="list" '+style_border+' width="100" >'+data[i][1]+'</td>';
			supplierList = supplierList + '  <td class="list" '+style_border+' width="70" >'+data[i][2]+'</td>';
			supplierList = supplierList + '  <td class="list" '+style_border+' width="130" >'+data[i][3]+'</td>';
			supplierList = supplierList + '  <td class="list" '+style_border+' width="130" >'+data[i][4]+'</td>';
			supplierList = supplierList + '  <td class="list" '+style_border+' width="" >'+data[i][5]+'</td>';
			supplierList = supplierList + '  <td class="list" '+style_border+' width="92" >'+comment+'</td>';
			supplierList = supplierList + '  <td class="list" '+style_border+' width="50" ><a href="javascript:void(0)" onclick="edit('+data[i][0]+')">编辑</a></td>';
			supplierList = supplierList + '</tr>';
			$('#supplier_list').append(supplierList);
		}
		if(data.length<_max){
			add_foot();
		}
	});
};
function add_foot(){
	var foot = '';
    foot = foot + '<tr>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="92" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="100" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="70" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="130" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="130" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="92" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="50" >&nbsp;</td>';
	foot = foot + '</tr>';
	$('#supplier_list').append(foot);
};
